<?php 
if ($section != "comments") {
		if ($action == "add") { 
		$insertSQL = sprintf("INSERT INTO course_description (cid, vid, cd_desc1, cd_desc2) VALUES (%s, %s, %s, %s)", 
			GetSQLValueString($cid, "int"),
			GetSQLValueString($_POST['vid'], "int"),
			GetSQLValueString($_POST['cd_desc1'], "text"),
			GetSQLValueString($_POST['cd_desc2'], "text")
		);
  						
		mysql_select_db($database, $connection);
  		$result1 = mysql_query($insertSQL, $connection) or die(mysql_error());
		
		$query_id_check = sprintf("SELECT id FROM %s WHERE cid='%s' AND vid='%s'", $dbTable, $cid, $_POST['vid']);
		$id_check = mysql_query($query_id_check, $connection) or die(mysql_error());
		$row_id_check = mysql_fetch_assoc($id_check);
		
			if (($section != "comments") && (($_POST['cd_desc1'] == "") || ($_POST['cd_desc2'] == ""))) {
			header("location:../index.php?section=".$section."&action=edit&dbTable=".$dbTable."&cid=".$cid."&vid=".$_POST['vid']."&id=".$row_id_check['id']."&go=missing&msg=2"); 
			}
			else {
				
				if ($go == "proposal_detail") $insertGoTo = "../index.php?section=view_proposal&cid=".$cid."&msg=2";
				elseif ($go == "default") $insertGoTo = "../index.php?section=cd&action=confirm&cid=".$cid."&vid=".$_POST['vid']."&id=".$row_id_check['id']."&msg=1";
				else $insertGoTo = $insertGoTo."&msg=3";
				header(sprintf("Location: %s", $insertGoTo));
			}
		}
		
		if (($action == "edit") && ($section != "comments")) { 
		$updateSQL = sprintf("UPDATE course_description SET cid=%s, vid=%s, cd_desc1=%s, cd_desc2=%s WHERE id=%s", 
			GetSQLValueString($cid, "int"),
			GetSQLValueString($_POST['vid'], "int"),
			GetSQLValueString($_POST['cd_desc1'], "text"),
			GetSQLValueString($_POST['cd_desc2'], "text"),
			GetSQLValueString($id, "int")
		);
  						
		mysql_select_db($database, $connection);
  		$result1 = mysql_query($updateSQL, $connection) or die(mysql_error());
		
		$query_id_check = sprintf("SELECT id FROM %s WHERE cid='%s' AND vid='%s'", $dbTable, $cid, $_POST['vid']);
		$id_check = mysql_query($query_id_check, $connection) or die(mysql_error());
		$row_id_check = mysql_fetch_assoc($id_check);
		
		if (($section != "comments") && (($_POST['cd_desc1'] == "") || ($_POST['cd_desc2'] == ""))) {
			header("location:../index.php?section=".$section."&action=edit&dbTable=".$dbTable."&cid=".$cid."&vid=".$_POST['vid']."&id=".$row_id_check['id']."&go=missing&msg=2"); 
			}
			else {
		if (($go == "no") || ($go == "missing")) $updateGoTo = "../index.php?section=cd&action=confirm&cid=".$cid."&vid=".$_POST['vid']."&id=".$id."&msg=1";
		//elseif ($go == "review") $updateGoTo = "../index.php?section=proposal_reveiw&cid=".$cid."&msg=2&modal_window=".$modal_window;
		//elseif ($go == "proposal_detail") $updateGoTo = "../index.php?section=view_proposal&cid=".$cid."&msg=2&amp;modal_window=".$modal_window;
		//elseif ($go == "default") $updateGoTo = "../index.php?section=cpd&action=add&cid=".$cid."&msg=3&modal_window=".$modal_window;
		//if ($section == "admin") $insertGoTo = "../index.php?section=list&msg=2";
		else $updateGoTo = $updateGoTo."&msg=4&modal_window=".$modal_window;
		header(sprintf("Location: %s", $updateGoTo));
			}
		}
	} // end if ($section != "comments") 
?>